package com.citi.gts.galto.modules.validation.vo;

import com.citi.gts.galto.core.tools.reference.Field;
import com.citi.gts.galto.core.tools.reference.Rejection;

import java.util.Set;

public class Repair {

    private Rejection rejection;

    private Set<Field> fieldSet;

    public Repair() {
    }

    public Rejection getRejection() {
        return rejection;
    }

    public void setRejection(Rejection rejection) {
        this.rejection = rejection;
    }

    public void setFieldSet(Set<Field> fieldSet) {
        this.fieldSet = fieldSet;
    }

    public Set<Field> getFieldSet() {
        return fieldSet;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder();
        sb.append("Repair");
        sb.append("{rejection=").append(rejection);
        sb.append(", fieldSet=").append(fieldSet);
        sb.append('}');
        return sb.toString();
    }

    public String fieldsInfo() {

        final StringBuilder sb = new StringBuilder(10);
        sb.append("{ ");

        final StringBuilder sbFor = new StringBuilder(10);
        for (Field field : fieldSet) {
            sbFor.append(' ');
            sbFor.append(field.getAlphabeticCode());
            sbFor.append(',');
        }

        sb.append(sbFor.substring(0, sbFor.length() - 1));
        sb.append(" }");

        return sb.toString();
    }

    public String rejectionInfo() {
        final StringBuilder sb = new StringBuilder(10);
        sb.append("Rejection Code: ").append(rejection.getAlphanumericCode());
        sb.append(", Rejection Type: ").append(rejection.getType());
        sb.append(", Rejection Description: ").append(rejection.getDescription());
        return sb.toString();
    }
}
